# JStdConfig.cmake
# --------------------
#
# JStd cmake module.
# This module sets the following variables in your project::
#
#   JStd_FOUND - true if JStd and all required components found on the system
#   JStd_VERSION - JStd version in format Major.Minor.Release
#   JStd_INCLUDE_DIRS - Directory where JStd header is located.
#   JStd_INCLUDE_DIR - same as DIRS
#   JStd_LIBRARIES - JStd library to link against.
#   JStd_LIBRARY - same as LIBRARIES
#
#
# Available components::
#
##   shared - search for only shared library
##   static - search for only static library
#   serial - search for unthreaded library
#   pthread - search for native pthread threaded library
#   openmp - search for OpenMP threaded library
#
#
# Exported targets::
#
# If JStd is found, this module defines the following :prop_tgt:`IMPORTED`
## target. Target is shared _or_ static, so, for both, use separate, not
## overlapping, installations. ::
#
#   JStd::JStd - the main JStd library #with header & defs attached.
#
#
# Suggested usage::
#
#   find_package(JStd)
#   find_package(JStd 0.2.20 EXACT CONFIG REQUIRED COMPONENTS pthread)
#
#
# The following variables can be set to guide the search for this package::
#
#   JStd_DIR - CMake variable, set to directory containing this Config file
#   CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package
#   PATH - environment variable, set to bin directory of this package
#   CMAKE_DISABLE_FIND_PACKAGE_JStd - CMake variable, disables
#     find_package(JStd) when not REQUIRED, perhaps to force internal build

@PACKAGE_INIT@

set(PN JStd)

# need to check that the @USE_*@ evaluate to something cmake can perform boolean logic upon
if (@USE_OPENMP@)
    set(${PN}_openmp_FOUND 1)
elseif(@USE_THREAD@)
    set(${PN}_pthread_FOUND 1)
else()
    set(${PN}_serial_FOUND 1)
endif()

check_required_components(${PN})

#-----------------------------------------------------------------------------
# Don't include targets if this file is being picked up by another
# project which has already built this as a subproject
#-----------------------------------------------------------------------------
if (NOT TARGET ${PN}::JStd)
    include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")

    get_property(_loc TARGET ${PN}::JStd PROPERTY LOCATION)
    set(${PN}_LIBRARY ${_loc})
    get_property(_ill TARGET ${PN}::JStd PROPERTY INTERFACE_LINK_LIBRARIES)
    set(${PN}_LIBRARIES ${_ill})

    get_property(_id TARGET ${PN}::JStd PROPERTY INCLUDE_DIRECTORIES)
    set(${PN}_INCLUDE_DIR ${_id})
    get_property(_iid TARGET ${PN}::JStd PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
    set(${PN}_INCLUDE_DIRS ${_iid})
endif()
